<?php


namespace App\Common;

use Qiniu\Auth;

class Upload
{
    public static function getUploadToken($type)
    {
        # todo type = 1 = admin,type = 2 = pc,type = 3 = 小程序
        if ($type == 1) {
            $url    = env('QINIU_VIDEO_DOMAIN');
            $bucket = env('QINIU_VIDEO_BUCKET');
        } else {
            $url    = env('QINIU_VIDEO_DOMAIN');
            $bucket = env('QINIU_VIDEO_BUCKET');
        }
        $auth  = new Auth(env('QINIU_ACCESS_KEY'), env('QINIU_SECRET_KEY'));
        $token = $auth->uploadToken($bucket,null,86400);
        return [
            'token'  => $token,
            'bucket' => $bucket,
            'picUrl' => $url
        ];
    }
}
